package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.DictMapper;
import com.lune.job.pojo.Dict;
import com.lune.job.pojo.ResPageBean;
import com.lune.job.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements IDictService {

    @Autowired
    private DictMapper dictMapper;

    /**
     * 分页查询字典
     * @param currentPage
     * @param size
     * @param dict
     * @return
     */
    @Override
    public ResPageBean getAllDictByPage(Integer currentPage, Integer size, Dict dict) {
        //开启分页
        Page<Dict> page = new Page<>(currentPage, size);

        IPage<Dict> dictIPage = dictMapper.getAllDictByPage(page, dict);

        ResPageBean resPageBean = new ResPageBean(dictIPage.getTotal(), dictIPage.getPages(), dictIPage.getRecords());
        System.out.println(dictIPage.getRecords());
        return resPageBean;
    }

    @Override
    public List<Dict> queryDict(Dict dict) {
        return dictMapper.queryDict(dict);
    }


}
